# Contributor: Sean E. Russell <ser@ser1.net>
# Maintainer: Sean E. Russell <ser@ser1.net>
pkgname=makeclapman
pkgver=2.4.1
pkgrel=3
pkgdesc="makeclapman generates man page(s) from programs that use the Go Claptrap flags library."
url="https://hg.sr.ht/~ser/claphelp"
arch="all"
license="BSD-3-Clause"
options="net"
makedepends="go"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://hg.sr.ht/~ser/claphelp/archive/v$pkgver.tar.gz"
builddir="$srcdir/claphelp-v$pkgver"
_pkgdate=2024-05-03   # The tag date, for the manpage

build() {
	go build -ldflags "-X main.Version=$pkgver" -v ./cmd/makeclapman

	mkdir man1
	CLAPTRAP_USAGE_JSON=true ./makeclapman | ./makeclapman -d man1 \
		--version $pkgver \
		--date $_pkgdate \
		--author "Sean E. Russell" \
		--description "makeclapman generates man page(s) from programs that use the Claptrap library. To use it, call the program with the environment variable CLAPTRAP_USAGE_JSON set and pipe the output to makeclapman. For example,

CLAPTRAP_USAGE_JSON=true yourprog | makeclapman"
}

check() {
	[ "$(./makeclapman version)" = "$pkgver" ]
}

package() {
	install -Dm755 makeclapman -t "$pkgdir"/usr/bin/
	install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/"$pkgname"/
	install -Dm644 man1/* -t "$pkgdir"/usr/share/man/man1/
}

sha512sums="
2965680dce3903c119b6c887356dee8e5991433e6ace60ded22b20d7effea30ff00df11a2b67be5958a4fe64aec9732a81c8c8eb52e96285953fa50c3768cd30  makeclapman-2.4.1.tar.gz
"
